package com.shuaihong.it.model.enums;

import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.databind.util.EnumResolver;
import lombok.Getter;

/**
 * 用户角色枚举切换
 */
@Getter
public enum UserRoleEnum {

    USER("用户", "user"),
    ADMIN("管理员", "admin");
    private final String text;

    private final String value;

    UserRoleEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    public static UserRoleEnum getEnumByValue(String val) {
        if (ObjectUtil.isEmpty(val)) {
            return null;
        }
        for (UserRoleEnum userRoleEnum : UserRoleEnum.values()) {
            if (userRoleEnum.getValue().equals(val)) {
                return userRoleEnum;
            }
        }
        return null;
    }
}
